#include <iostream>
#include <fstream>
#include <stdexcept>
#include "line_stream_iterator.hpp"

using namespace std;

int main(int argc, char* argv[])
{
	//step1: help
	if (argc != 2)
	{
		cout << "usage: ./main input.txt" << endl;
		return -1;
	}

	//step2: read file
	ifstream is(argv[1]);
	if (!is)
		throw runtime_error(string("can not open \"" + string(argv[1]) + "\" to read").c_str());

	//step3: init
	line_stream_iterator<> litr(is);
	line_stream_iterator<> lend;
	
	//step4: print each line
	for (; litr != lend; ++litr) 
	{
		cout << *litr << endl;
	}

	//step5: return
	return 0;
}
